<template>
  <view :class="'background '+$store.state.account.addAccountChooseListPage.extraClass"
        v-if="$store.state.account.addAccountChooseListPage.show">
    <view class="page-container-add-account-choose-list">
      <view class="header-section">
        <view class="back" @click="goBack">
          返回
        </view>
        <view class="header-section-title">
          添加账户

        </view>
        <view class="close" @click="goBack">
          x
        </view>

      </view>
      <view class="body-section">

        <ul >
          <li v-for="(item, index) in list" :key="index" @click="e=>openForm(item)">
            <view class="left-side">
              <view class="icon-box">
                <svg-icon :icon="item.name" :width="30" :height="30"></svg-icon>
              </view>
              <view class="span-box">
                <span>{{item.name}}</span>
              </view>
            </view>
            <view class="right-side">
              <view class="right-arrow">
              </view>
            </view>

          </li>
        </ul>

      </view>

    </view>

  </view>
</template>

<script>

import {mapState} from "vuex";

import SvgIcon from "@/pages/svg-icon.vue";
export default {
  components: {SvgIcon},
  data() {
    return {
      list:[
        {name:'现金'}  ,
        {name:'储蓄卡'}  ,
        {name:'信用卡'}  ,
        {name:'虚拟账户'}  ,
        {name:'投资账户'}  ,
        {name:'负债'}  ,
        {name:'债权'}  ,
        {name:'自定义资产'}  ,
      ],
    }

  },
  methods: {
    openForm(item){
      console.log("openForm")
      if(item.name === '现金'){
        this.$store.dispatch('ENTER_ADD_ACCOUNT_CHOOSE_FORM_PAGE')
      }else if(item.name === '储蓄卡'){
        this.$store.dispatch('ENTER_ADD_ACCOUNT_SAVING_CARD_LIST_PAGE')
      }else if(item.name === '信用卡'){
        this.$store.dispatch('ENTER_ADD_ACCOUNT_CREDIT_CARD_LIST_PAGE')
      }else if(item.name === '虚拟账户'){
        this.$store.dispatch('ENTER_ADD_ACCOUNT_VIRTUAL_CARD_LIST_PAGE')
      }else if(item.name === '投资账户'){
        this.$store.dispatch('ENTER_ADD_ACCOUNT_INVESTMENT_ACCOUNT_LIST_PAGE')
      }else if(item.name === '负债'){

      }


    },
    goBack() {
      this.$store.dispatch("LEAVE_ADD_ACCOUNT_CHOOSE_LIST_PAGE")
    }

  },

}
</script>


<style scoped>

.background {
  //width: 100vw;
  //height: 100vh;
  background: #f2f2f6;
  position: absolute;
  left: 0;
  bottom: 0;
  top: 0;
  right: 0;
  z-index: 1000 !important;
}

.background-animation-none {
  top: 100%;
}

.background-animation-enter {

  animation-name: hd-enter;
  animation-duration: 300ms;
}

.background-animation-leave {

  animation-name: hd-leave;
  animation-duration: 300ms;
  top: 100%;
}

@keyframes hd-enter {
  0% {
    top: 100%;
  }
  100% {
    top: 0
  }
}

@keyframes hd-leave {
  0% {
    top: 0;
  }
  100% {
    top: 100%;
  }
}

.page-container-add-account-choose-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: scroll;

}

.page-container-add-account-choose-list .header-section {
  background: pink;
  min-height: 50px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.page-container-add-account-choose-list .header-section .back {
    width: 40px;
    margin-left: 20px;
    position: relative;
  }

.page-container-add-account-choose-list .header-section .back::before {
    content: "";
    width: 12px !important;
    height: 12px !important;
    border-top: 2px solid #000;
    border-right: 2px solid #000;
    transform: rotate(225deg);
    position: absolute;
    top: 4px;
    left: -11px;
}

.page-container-add-account-choose-list  .close {
    width: 40px;
    margin-right: 20px;
    text-align: right;
  }


.page-container-add-account-choose-list ul {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  width: 100%;
  //background: red;

}

.page-container-add-account-choose-list ul li {
  list-style: none;
  height: 60px;
  font-size: 20px;
  border-bottom: 1px solid rgb(245, 245, 245);
  display: flex;
  flex-direction: row;

  width: 100%;
}

.page-container-add-account-choose-list .left-side {
  display: flex;
  flex-direction: row;
  align-items: center;

}
.page-container-add-account-choose-list .body-section{
  background: #fff;
  margin-top: 10px;
  overflow-y: scroll;
}
.page-container-add-account-choose-list .body-section .left-side .icon-box {
  margin-left: 20px;

}

.page-container-add-account-choose-list .body-section .left-side .span-box {
  margin-left: 12px;
}

.page-container-add-account-choose-list .body-section .right-side {
  position: relative;
  flex: 1;

}

.page-container-add-account-choose-list .body-section .right-side .right-arrow {

  content: "";
  width: 10px !important;
  height: 10px !important;
  border-top: 2px solid #aaa;
  border-right: 2px solid #aaa;
  transform: rotate(45deg);
  position: absolute;
  top:25px;
  right: 16px;


}
</style>
